package searchteam.client.ui.callbacks;

import java.util.Collection;

import searchteam.client.beansMirrors.PaperMirror;
import searchteam.client.ui.widgets.Display;
import searchteam.client.ui.widgets.InfoPopUp;
import searchteam.client.ui.widgets.PaperMirrorDisplay;

import com.google.gwt.user.client.rpc.AsyncCallback;

public class getAllPapersCallback implements AsyncCallback<Collection<PaperMirror>> {

	private Display dataPanel;
	
	public getAllPapersCallback(Display dataPanel) {
		this.dataPanel = dataPanel;
	}
	
	public void onFailure(Throwable caught) {
		dataPanel.clearMirrors();
		new InfoPopUp(caught.getMessage(), "Erreur");
	}

	public void onSuccess(Collection<PaperMirror> result) {
		dataPanel.clearMirrors();
		
		for(PaperMirror paperMirror : result) {
			dataPanel.addMirror(new PaperMirrorDisplay(dataPanel, paperMirror));
		}
	}

}
